package io.ganguo.chat.route.biz.repository;

import io.ganguo.chat.route.biz.entity.Message;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Tony on 2/23/15.
 */
@Repository
public interface MessageRepository extends CrudRepository<Message, BigInteger> {
    List<Message> findByFrom(Long from);

    List<Message> findByTo(Long to);


    List<Message> findByToOrderByCreateAtDesc(Long to);

    List<Message> findByToOrderByCreateAtAsc(Long to);
   /* public interface PersonRepository extends Repository < User , Long > {

        List<Person> findByEmailAddressAndLastname (EmailAddress emailAddress, String lastname) ;

// Enables the distinct flag for the query

        List<Person> findDistinctPeopleByLastnameOrFirstname (String lastname, String firstname) ;

        List<Person> findPeopleDistinctByLastnameOrFirstname (String lastname, String firstname) ;

// Enabling ignoring case for an individual property

        List<Person> findByLastnameIgnoreCase (String lastname) ;

// Enabling ignoring case for all suitable properties

        List<Person> findByLastnameAndFirstnameAllIgnoreCase (String lastname, String firstname) ;

// Enabling static ORDER BY for a query

        List<Person> findByLastnameOrderByFirstnameAsc (String lastname) ;

        List<Person> findByLastnameOrderByFirstnameDesc (String lastname) ;

        User findFirstByOrderByLastname () ;

User findTopByOrderByAgeDesc () ;

Page<User> queryFirst10ByLastname (String lastname, Pageable pageable) ;

Slice<User> findTop3ByLastname (String lastname, Pageable pageable) ;

List<User> findFirst10ByLastname (String lastname, Sort sort) ;

List<User> findTop10ByLastname (String lastname, Pageable pageable) ;

    }*/
}

/**
 * 方法名应该是find…By, read…By, query…By, count…By, and get…By这样的格式。可以设置Distinct 和 And , Or :
 */